﻿namespace ClickLand.CorporacionPlaza.AccesoDato.Implementacion.NHibernateMySql
{
    public static class NHibernateSql
    {
        public static string Query { get; set; }

        public static string FormatSql(string querySinFormato)
        {
            string upperQuerySinFormato = querySinFormato.ToUpper();

            string newSQL = upperQuerySinFormato.Replace("SELECT", "SELECT\n\t");
            newSQL = newSQL.Replace("FROM", "\nFROM\n\t");
            newSQL = newSQL.Replace("WHERE", "\nWHERE\n\t");
            newSQL = newSQL.Replace("=", " = ");
            newSQL = newSQL.Replace(",", ",\n\t");
            newSQL = newSQL.Replace(" AND", " AND\n\t");
            newSQL = newSQL.Replace(" ON", "\n\t\tON");
            newSQL = newSQL.Replace("INNER JOIN", "\n\tINNER JOIN");
            newSQL = newSQL.Replace("ORDER BY", "\nORDER\t BY");
            newSQL = newSQL.Replace("GROUP BY", "\nGROUP\t BY");
            newSQL = newSQL.Replace(" AS", " \tAS");

            return newSQL;
        }
    }
}
